package com.ruoyi.bus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.BusWay;
import com.ruoyi.bus.service.IBusWayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中途站Controller
 * 
 * @author ruoyi
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/bus/way")
public class BusWayController extends BaseController
{
    @Autowired
    private IBusWayService busWayService;

    /**
     * 查询中途站列表
     */
   // @PreAuthorize("@ss.hasPermi('bus:way:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWay busWay)
    {
        startPage();
        List<BusWay> list = busWayService.selectBusWayList(busWay);
        return getDataTable(list);
    }

    /**
     * 导出中途站列表
     */
    @PreAuthorize("@ss.hasPermi('bus:way:export')")
    @Log(title = "中途站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWay busWay)
    {
        List<BusWay> list = busWayService.selectBusWayList(busWay);
        ExcelUtil<BusWay> util = new ExcelUtil<BusWay>(BusWay.class);
        util.exportExcel(response, list, "中途站数据");
    }

    /**
     * 获取中途站详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:way:query')")
    @GetMapping(value = "/{buswayID}")
    public AjaxResult getInfo(@PathVariable("buswayID") Long buswayID)
    {
        return success(busWayService.selectBusWayByBuswayID(buswayID));
    }

    /**
     * 新增中途站
     */
    @PreAuthorize("@ss.hasPermi('bus:way:add')")
    @Log(title = "中途站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusWay busWay)
    {
        return toAjax(busWayService.insertBusWay(busWay));
    }

    /**
     * 修改中途站
     */
    @PreAuthorize("@ss.hasPermi('bus:way:edit')")
    @Log(title = "中途站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusWay busWay)
    {
        return toAjax(busWayService.updateBusWay(busWay));
    }

    /**
     * 删除中途站
     */
    @PreAuthorize("@ss.hasPermi('bus:way:remove')")
    @Log(title = "中途站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{buswayIDs}")
    public AjaxResult remove(@PathVariable Long[] buswayIDs)
    {
        return toAjax(busWayService.deleteBusWayByBuswayIDs(buswayIDs));
    }
}
